4 _root="$(dirname "${0}")/.."; . "${_root}/lib/sh/env.sh"
12 log "Usage: $(basename "${0}") <command> [rcscript]"
14 log "<command> can be one of:"
15 log " list - List all available rcscripts"
16 log " status - Show status for all rcscripts"
20 log " on - List all currently running scripts"
23 log " off - List all currently stopped scripts"
25 log "You can also send a command to any rcscript with the following form:"
26 log " $(basename "${0}") <command> [rcscript]"
28 log "For example, the following is equivalent to running '/etc/rc.d/ppp stop':"
29 log " $(basename "${0}") stop ppp"
34 # All startup directories
36 for dir in /etc/rc.d ${local_startup}
38 [ -d "${dir}" ] && echo "${dir}"'/*'
42 # List all available rc scripts
44 ls -1 $(rc_dirs) | egrep -v '/(DAEMON|FILESYSTEMS|LOGIN|NETWORKING|SERVERS)$' | sort
47 # Get the status of one script
50 [ -x "${file}" ] && "${file}" status > /dev/null 2>&1
53 # Get the status of all scripts
59 list) rc_list | sed -e 's/^.*\///'; return ;;
60 started|running|on) want="1" ;;
61 stopped|off) want="0" ;;
66 rc_list | while read file
68 name="$(basename "${file}")"
69 if rc_status "${file}"
71 [ ! "${want}" -o "${want}" = "1" ] && log "${a_green}running${a_normal}: ${name}"
73 [ ! "${want}" -o "${want}" = "0" ] && log "${a_red}stopped${a_normal}: ${name}"
78 # Perform an action on the script
82 rc_list | grep "/${2}$" | while read rcd; do "${rcd}" "${1}"; done
86 1) rc_statii "${1}" ;;
87 2) rc_action "${1}" "${2}" ;;